package com.woniu.cq.springboot_mybatisplus_shiro.comment;

import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * @Author: Klaus
 * @Date: 2020/9/3 11:46
 */
public class EncryptUtil {
    public static  final  String ALGORITHM_NAME="SHA-256";
    public static  final  int HASH_ITERATIONS=1;

    /**
     * 加密方法
     * @param password
     * @return
     */
    public static String encrypt(String password){
        return encrypt(password,null);
    }

    /**
     * 加密方法
     * @param password
     * @return
     */
    public static String encrypt(String password,String salt){
        SimpleHash simpleHash = new SimpleHash(ALGORITHM_NAME,password,salt,HASH_ITERATIONS);
        return simpleHash.toHex();
    }

    public static void main(String[] args) {
        String encrypt = encrypt("123");
        System.out.println(encrypt);
    }

}
